package com.neu.util;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import com.neu.po.ResponseResult;

//@ControllerAdvice
public class GlobaExceptionHandler {
	//@RestController=@Controller+@ResponseBody
	//能够基于底层的配置，把返回值转换为json对象写入到http数据区
	
	@ResponseBody
	@ExceptionHandler(Exception.class)
	public ResponseResult exceptionHandler(Exception ex) {

		ResponseResult result = new ResponseResult();
		result.setResult("error");
		
		result.setData(ex.getMessage());
		
		return result;
		
		
		
	}
}
